package net.yihang.miaosha.util;

import net.yihang.miaosha.controller.LoginController;
import net.yihang.miaosha.domain.MiaoshaUserKey;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

public class CookieUtil {
    public static void updateTokenCookie(HttpServletResponse response, MiaoshaUserKey key) {
        Cookie cookie = new Cookie(LoginController.LOGIN_TOKEN_NAME, key.key());
        cookie.setMaxAge(key.expireTime());
        cookie.setHttpOnly(true);
        cookie.setPath("/");
        response.addCookie(cookie);
    }
}
